<template>
    <page-frame>
      <div class="assessmentScale">
        <div class="toptitle">
          <div class="left">评估量表</div>
          <div class="right">
            <div class="btns">
              <el-button @click="addStaff" class="lightGreenBtn">新增量表</el-button>
            </div>
          </div>
        </div>
        <div class="borderT"></div>
        <div class="file-main">
          <div class="tabs">
            <el-table
              :data="tableData"
              border
              highlight-current-row
              @cell-dblclick="schedule=true"
              style="width: 100%">
              <el-table-column
                prop="sheetName"
                label="评估量表名称"
                width="180"
              >
              </el-table-column>
              <el-table-column
                prop="assessSetNames"
                label="评估项目"
                width="400"
              >
              </el-table-column>
              <el-table-column
                prop="assessSheetResultNames"
                label="评估结果"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="operating"
                label="操作"
                width="140">
                <template scope="scope">
                  <el-button type="text" size="small" @click.stop="editSheet(scope.row.sheetId)">修改</el-button>
                  <el-button type="text" size="small" @click.stop="deleteSheet(scope.row.sheetId)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>

            <div class="pagination">
              <div class="block">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChangePage"
                  :current-page="pageData.currentPage1"
                  :page-size="10"
                  layout="total, prev, pager, next"
                  :total="total">
                </el-pagination>
              </div>
            </div>
          </div>
        </div>
      </div>
    </page-frame>
</template>

<script >
  import Vue from 'vue'
  import VueResource from 'vue-resource';
  Vue.use(VueResource);
  export default {
    methods: {
      init(){
        console.log("======3333========");
        this.loadTableData();
      },
      addStaff(){
        this.$router.push({name: 'addScale'});
      },
      loadTableData(){
        let self = this;
        console.log("==============");
        Vue.http.get("/assessSheet/m/v1/getAssessSheets/" + 10 + "/" + self.currentPage).then(
          (response) => {
          console.log(response.data);
        self.tableData = response.data.data.list;
        self.total = response.data.data.total;
      },
        (response) => {},
      );
      },
      retreat(){
        this.$router.push({name: "checkInProcess01"});
      },
      editSheet(sheetId){
          this.$router.push({name: "redactScale",query:{sheetId:sheetId}});
      },
      //删除有问题
      deleteSheet(sheetId){
        let self = this;
        console.log("删除");
        self.$confirm('请确认是否删除评估量表信息', '删除评估量表信息', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          Vue.http.post("/assessSheet/m/v1/deleteAssessSheet/"+sheetId).then(function(){
          self.$message({
            type: 'success',
            message: '删除成功!'
          });
          self.loadTableData();
        },function(){});
      }).catch(() => {
          self.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
      },
      handleCurrentChange(val) {

      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChangePage(val) {
        this.currentPage = val;
        console.log(`当前页: ${val}`);
        this.loadTableData(val);
      },
    },
    mounted: function () {
      this.init();
      console.log("======3333==ddddd======");

    },
    components: {
      'my-compont1': {
//        props:['msg'], /*这里是为子模板传值*/
        template: "<input type='text' value='my-compont1'/>"
      },
      'my-compont2': {
//        props:['msg'], /*这里是为子模板传值*/
        template: "<input type='text' value='my-compont2'/>"
      }
    },
    data () {
      return {
        leaveDate: "",
        leave: false,
        currentPage:1,
        deleteItem: "",
        staffLeave: {
          emId: null,
          termdate: '',
        },
        schedule: false,
        queryData: {},
        fileList: [{
          fileId: 1,
          fileName: "评估量表名称"
        }, {
          fileId: 2,
          fileName: "评估项目",
        }, {
          fileId: 3,
          fileName: "评估结果",
        }],
        tableData: [{
          "sheetId": 1,
          "sheetName": "",
          "assessSetNames": "",
          "assessSheetResultNames": "",
        }],
        total: 1,
        pageData: [{
          currentPage1: 1,
        }],
      }
    },
  }
</script>
<style>

  .assessmentScale .input .btns{
    float:none!important;
    display:inline-block;
  }
  .assessmentScale .el-input{
    width: 80%;
  }
  .assessmentScale .input input{
    display: inline-block;
  }
  .assessmentScale .scroll{
    height: calc(100vh - 122px);
    padding:0px 50px;
  }
  .assessmentScale .el-pagination{
    margin-right:0!important;
    padding-right:0!important;
  }
  .assessmentScale .el-select {
    display: block;
    position: relative;
  }
  .assessmentScale .query{
    margin-right:30px;
  }
</style>
